package com.txd.mofa.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ninetaildemonfox.zdl.ninetails.map.JSONUtils;
import com.txd.mofa.R;

import java.util.ArrayList;
import java.util.Map;

public class FenleiAdapter extends BaseQuickAdapter<Map<String, String>, BaseViewHolder> {

    private Onclick onclick;

    public FenleiAdapter(int layoutResId) {
        super(layoutResId);
    }

    public void setOnclick(Onclick onclick){

        this.onclick = onclick;
    }
    public interface Onclick{
        void click(int poss,int pos);
    }

    @Override
    protected void convert(BaseViewHolder helper, Map<String, String> item) {


        helper.setText(R.id.tv,item.get("title"));

        ArrayList<Map<String, String>> child_two = JSONUtils.parseKeyAndValueToMapList(item.get("child_two"));

        RecyclerView recy = helper.getView(R.id.recy);

        GridLayoutManager gridLayoutManager1 = new GridLayoutManager(mContext,3);

        recy.setLayoutManager(gridLayoutManager1);

        FenleiAdapter1 fenleiAdapter = new FenleiAdapter1(R.layout.item_fenlei1);
        recy.setAdapter(fenleiAdapter);

        fenleiAdapter.setNewData(child_two);

        fenleiAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                onclick.click(helper.getPosition(),position);
            }
        });

    }
}
